package com.megvii.koala.components;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.megvii.koala.R;

/**
 * Created by linyue on 15/12/30.
 */
public class ListBottomView extends RelativeLayout
{
    protected View container;

    protected TextView textView;

    protected ProgressBar progressBar;

    public ListBottomView(Context context)
    {
        super(context);
        init(context, null);
    }

    public ListBottomView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        init(context, attrs);
    }

    public ListBottomView(Context context, AttributeSet attrs, int defStyle)
    {
        super(context, attrs, defStyle);
        init(context, attrs);
    }

    private void init(Context context, AttributeSet attrs)
    {
        inflate(context, R.layout.bottom_item, this);
        container = findViewById(R.id.bottom_item_container);
        textView = (TextView) findViewById(R.id.bottom_item_text);
        progressBar = (ProgressBar) findViewById(R.id.bottom_item_progress);
    }

    public void setHasMore(boolean hasMore)
    {
        //textView.setVisibility(hasMore ? View.GONE : View.VISIBLE);
        container.setVisibility(View.GONE);
        progressBar.setVisibility(hasMore ? View.VISIBLE : View.GONE);
    }
}
